<h1><span></span><?= lang('label_resloution_center'); ?></h1>

<ul class="breadcrumb">
    <li><a href="<?= base_url() ?>"><?= lang('label_home') ?></a></li>
    <li><a href="<?= base_url('user/profile') ?>"><?= lang('label_profile') ?></a></li>
    <li><?= lang('label_resloution_center'); ?></li>
</ul>


<div class="page">

    <?php $this->load->view('template/default/cases/top') ?>

    <div style="overflow:hidden;">

        <?php $this->load->view('template/default/cases/side'); ?>
        <div class="profile_page">
            <h2 class="profile_page_title"><?= lang('label_resloution_center'); ?> &raquo; <strong><?= lang('label_resolution_' . $type) ?></strong></h2>

            <?php if ($result) { ?>
                <form action="<?php echo current_url() ?>/all/" method="post">
                    <table id="tablestyle">
                        <thead>
                            <tr>
                                <th><?= lang('label_product_name') ?></th>
                                <th><?= lang('label_created_date') ?></th>
                                <th><?= lang('label_store') ?></th>
                                <th><?= lang('label_count_replay') ?></th>
                                <th><?= lang('label_last_user_replay') ?></th>
                                <th><?= lang('label_operation') ?></th>
                            </tr>
                        </thead>

                        <tbody>
                            <?php
                            foreach ($result as $value) {
                                $allreplaies = get_case_replaies($value->id);
                                if($allreplaies)
                                $reply = get_cases_last_replay($value->id);
                                ?>
                                <tr>
                                    <td>
                                        <div class="checkbox">
                                            <label for="privacy<?php echo $value->id; ?>"><a href="<?php echo base_url(get_segment(1) . "/view/$value->id") ?>"><?= $value->name ?></a>
                                            </label>
                                            <br/>
                                            <small><?php echo substr($value->reson, 0, 190) ?> ...</small>
                                        </div>
                                    </td>
                                    <td><?= '<strong>'.get_username_with_id($value->user_id).'</strong><br />'.$value->create_date ?></td>
                                    <td><?= get_store_name_by_id($value->store_id) ?></td>
                                    <td><?= $allreplaies ?></td>
                                    <td style="text-align: center"><?= (isset($reply)) ? '<strong>'.$reply->Username.'</strong><br />'.$reply->create_date : ' ---- '; ?></td>
                                    <td>
                                        <a class="store_but" href="<?= base_url(get_segment(1) . "/view/$value->id") ?>"><?= lang('label_view') ?></a>
                                        <?php if ($value->user_id == $this->user_id && $value->close == 'NO') { ?>
                                        <a class="store_but" href="<?= base_url(get_segment(1)."/close/$value->id"); ?>"><?= lang('label_close') ?></a>
                                        <?php } elseif (in_array($value->close, array('USER','ADMIN'))) { ?>
                                        <span style="clear: both" class="closedy"><?= lang("label_closed_by_$value->close") ?></span>
                                            <?php
                                        }
                                        ?>
                                    </td>
                                </tr>
                                <?php
                            }
                            ?>

                        </tbody>
                    </table>
                </form>
            <?php } else { ?>
                <div class="unsaved">
                    <img src="<?php echo str_replace('/index.php', '', $_SERVER['SCRIPT_NAME']) ?>/<?php echo APPPATH ?>views/<?php echo $this->themes->Cms_themes() ?>/images/unsaved.png" alt="" />
                    <br /><?= lang('message_no_casses_found') ?>
                </div>
                <br /><br /><br /><br />
            <?php } ?>
        </div></div></div>